package com.cgsrp.cgsrp_baby.controller;

import com.cgsrp.cgsrp_baby.domain.ChildParent;
import com.cgsrp.cgsrp_baby.domain.Message;
import com.cgsrp.cgsrp_baby.service.ChildParentRelationService;
import com.cgsrp.cgsrp_baby.service.ChildParentService;
import com.cgsrp.utils.Result;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("bp")
public class BabyChildParentController {

    @Autowired
    private ChildParentService childParentService;
    @Autowired
    private ChildParentRelationService relationService;

    @GetMapping("list")
    public PageInfo<ChildParent> list(
            @RequestParam()int[] babyIds,
            @RequestParam(defaultValue = "1")Integer curPage,
            @RequestParam(defaultValue = "3")Integer pageSize
    ){
        return childParentService.list(babyIds,curPage,pageSize);
    }

    @PostMapping("add")
    public boolean add(int babyId,String phone,String relationship,String name){
        return relationService.add(babyId,phone,relationship,name);
    }

    @PostMapping("del")
    public boolean del(int childId,int parentId,String name){
        return relationService.del(childId,parentId,name);
    }

    @PostMapping("accept")
    public Result accept(Message message){
        return relationService.accept(message);
    }
}

